// 雷达图

export default function getRadarChar(optionSet = []) {
  console.log('optionSet', optionSet);
  // const res = {
  //   data: [],
  //   indicator: []
  // };

  // optionSet.forEach(i => {
  //   res.data.push({
  //     value: [],
  //     name: i.label
  //   });

  //   res.indicator.concat(i.data);
  // });

  const res = { data: [], indicator: [] };

  console.log(res);
  optionSet.forEach(i => {
    res.data.push({
      value: [],
      name: i.label
    });

    i.data.forEach(j => {
      res.indicator.push({
        name: j.name,
        max: j.value
      });
    });
  });

  const option = {
    tooltip: {},
    legend: {
      data: res.data.map(item => item.name)
    },
    radar: {
      // shape: 'circle',
      name: {
        textStyle: {
          color: '#fff',
          backgroundColor: '#999',
          borderRadius: 3,
          padding: [3, 5]
        }
      },
      indicator: res.indicator
    },
    series: [
      {
        name: '预算 vs 开销（Budget vs spending）',
        type: 'radar',
        // areaStyle: {normal: {}},
        data: res.data
      }
    ]
  };

  return option;
}
